package com.wxh.order.feign;

import com.wxh.order.entity.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 使用feign的FallbackFactory
 *
 * @author wxh
 */
@Component
public class UserFeignFallBackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getUser(Long userId) {
                throw new RuntimeException("请求用户接口异常");
            }

            @Override
            public User getUser(User user) {
                throw new RuntimeException("请求用户接口异常");
            }
        };
    }
}
